#ifndef __DBCONN_POOL_H__
#define __DBCONN_POOL_H__

#include <my_header.h>

// 检查数据库返回值，打印错误信息
#define MYSQL_ERROR_CHECK(ret, error_flag, msg, mysql) \
    do {\
        if ((ret) == (error_flag)) { \
            fprintf(stderr,"%s:%s\n",msg,mysql_error(mysql));\
            exit(1); \
        } \
    } while (0)
// 数据库连接池
#define MAX_CONN_NUM 10
typedef struct dbConnPool_s {
    int connNum;
    int *statusArr; // 连接状态
    MYSQL **dbConnArr;// 连接的数组
} dbConnPool_t;

int db_conn_pool_init(dbConnPool_t *connectPool, int workernum);
int get_dbconn(dbConnPool_t *dbconnPool, MYSQL **mysql);

#endif
